require "Common/define"
require "Logic/Config"
require "Common/functions"

RedDotsRuneChangeHandler ={}
local this = RedDotsRuneChangeHandler
local specialIndex = 6

function RedDotsRuneChangeHandler.init()
    return this
end

function RedDotsRuneChangeHandler.getFlag(...)
    local partnerId,index = ...
    if partnerId and index then
        local runeData = logicMgr.RuneManager.GetHeroRuneSrvInfo(partnerId, index)
        if runeData then
            local stuffCommonRuneList = logicMgr.RuneManager.GetCommonStuffRuneList()
            local stuffSpecialRuneList = logicMgr.RuneManager.GetSpecialStuffRuneList()
            if index == specialIndex then
                if stuffSpecialRuneList and stuffSpecialRuneList[1] then
                    if runeData.power < stuffSpecialRuneList[1].power then
                        return Config.RedDotsFlagState.Needful
                    end
                end
            else
                if stuffCommonRuneList and stuffCommonRuneList[1] then
                    if runeData.power < stuffCommonRuneList[1].power then
                        return Config.RedDotsFlagState.Needful
                    end
                end
            end
        end
    end
    return Config.RedDotsFlagState.None
end

function RedDotsRuneChangeHandler.update()
    RedDotsManager.addBroadcast(Config.RedDotsType.RuneLevelUp);
end
